package com.loop.unclelend.ui.adapter

import androidx.recyclerview.widget.RecyclerView
import com.loop.unclelend.R
import com.loop.unclelend.utils.adapter.UncleRecyclerViewAdapter
import com.loop.unclelend.utils.adapter.UncleViewHolderHelper
import org.json.JSONObject

/**
 * UncleLend
 * @Author wwdeng
 * @CreateTime: 2024/9/28 16:42
 * @Annotation：消息列表适配器
 */
class Adapter_Message(recyclerView: RecyclerView?) : UncleRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.uncle_item_message) {
    override fun setItemChildListener(helper: UncleViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.layout_item)
    }

    override fun fillData(helper: UncleViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.txt_title,model.optString("title"))
        helper.setText(R.id.txt_time,model.optString("timeDesc"))
        helper.setText(R.id.txt_desc,model.optString("content"))

        val imgView = helper.getImageView(R.id.img_logo)
        when(model.optString("type")){
            "REPAY_REMIDER" -> {//还款提醒
                imgView.setImageResource(R.mipmap.icon_message_repayment)
            }
            "APPLY_STATUS_UPDATE" -> {//申请状态更新
                imgView.setImageResource(R.mipmap.icon_message_apply_update)
            }
            else -> {//AD_MESSAGE  广告推广
                imgView.setImageResource(R.mipmap.icon_message_custom)
            }
        }
    }
}